<?php
/* @var $this CustomerController */
/* @var $model Customer */

$this->breadcrumbs=array(
        'Customers'=>array('index'),
        $model->id,
);

$this->menu=array(
        array('label'=>'List Customer', 'url'=>array('index')),
        array('label'=>'Create Customer', 'url'=>array('create')),
        array('label'=>'Update Customer', 'url'=>array('update', 'id'=>$model->id)),
        array('label'=>'Delete Customer', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
        array('label'=>'Manage Customer', 'url'=>array('admin')),
		array('label'=>'Create Reservation', 'url'=>array('reservation/create', 'customer_id'=>$model->id)),
);
?>

<h1>View Customer #<?php echo $model->id; ?></h1>

<?php $this->widget('zii.widgets.CDetailView', array(
        'data'=>$model,
        'attributes'=>array(
                'fname',
                'lname',
                'mi',
                'contact_no',
                'address',
                'create_at',
        ),
)); ?>

<?php $customerid= $model->id;?>

<?php $res=Reservation::model()->findAll('customer_id = :a', array(':a'=>$model->id));?>
<?php if (count($res) !== 0){?>
<br>
<h1>Reservations</h1>
<?php foreach ($res as $model) { ?>
<?php echo CHtml::link('<img src="' . Yii::app()->request->baseUrl . '/images/update.png" align="right"/>', 
array('reservation/update', 'id'=>$model->id)); ?>
<?php $this->widget ('zii.widgets.CdetailView', array(
	'data'=>$model,
	'attributes'=>array(
	array(               
            'label'=>'Service Type',
            'type'=>'raw',
            'value'=>CHtml::link(CHtml::encode($model->service['type']), array('service/view','id'=>$model->service->id)),
        ),
		array(               
            'label'=>'Service Price',
            'type'=>'raw',
            'value'=>CHtml::encode(CHtml::encode($model->service['price']), array('service/view','id'=>$model->service->id)),
        ),
		array(               
            'label'=>'Attendant',
            'type'=>'raw',
            'value'=>CHtml::link(CHtml::encode($model->attendant['fname']), array('attendant/view','id'=>$model->attendant->id)),
        ),
		array(               
            'label'=>'Bed',
            'type'=>'raw',
            'value'=>CHtml::encode($model->bed['bed_name']),
        ),
		'reservation_type',
		'reservation_date',
		'start_time',
		'end_time',
	),
));
?><br>
<?php }} ?>

